#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "Num.h"

/**
 * Program 3.2 Types of numbers
 * ----------------------------
 * 编译：
 * gcc -o avg avg.c int.c
 * ----------------------------
 * 运行：
 * ./avg 10
 */
int main(int argc, char** argv) {
    int i;
    int N = atoi(argv[1]);
    float m1 = 0.0;
    float m2 = 0.0;
    Number x;

    for (i = 0; i < N; i++) {
        x = randNum();
        m1 += ((float)x)/N;
        m2 += ((float)(x*x))/N;
    }

    printf("Average: %f\n", m1);
    printf("Std. deviation: %f\n", sqrt(m2 - m1*m1));

    return 0;
}